package com.jsyh.maidu.presenter;

import android.app.Activity;

import com.jsyh.maidu.config.ConfigValue;
import com.jsyh.maidu.http.BaseDelegate;
import com.jsyh.maidu.http.ExceptionHelper;
import com.jsyh.maidu.http.OkHttpClientManager;
import com.jsyh.maidu.model.BaseModel;
import com.jsyh.maidu.utils.Utils;
import com.squareup.okhttp.Request;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by admin on 2017/6/28.
 */

public class SavaEvaluatePresenter extends BasePresenter{


    Activity context;

    public SavaEvaluatePresenter(Activity context )
    {
        this.context=context;

    }

    public void laodSave(String orderid, final String content, String commrank, String svrank, String sendrank, String shiprank, String hide)
    {
        initLoadDialog(context);
        mLoadingDialog.show();
        Map<String,String> params=new HashMap();
        params.put("key", ConfigValue.DATA_KEY);
        params.put("rec_id",orderid);
        params.put("content",content);
        params.put("comment_rank",commrank);
        params.put("server_rank",svrank);
        params.put("send_rank",sendrank);
        params.put("shipping_rank",shiprank);
        params.put("hide_name",hide);

        OkHttpClientManager.postAsyn(context, ConfigValue.APP_IP + "msg/saveComments", params, new BaseDelegate.ResultCallback<BaseModel>() {
            @Override
            public void onError(Request request, Object tag, Exception e) {
                mLoadingDialog.dismiss();
                Utils.showToast(context, ExceptionHelper.getMessage(e,context));
            }

            @Override
            public void onResponse(BaseModel response, Object tag) {
                mLoadingDialog.dismiss();
                if (response.getCode().equals("1"))
                {
                    context.finish();
                    Utils.showToast(context, response.getMsg());
                }else {
                    Utils.showToast(context, response.getMsg());
                }


            }
        });

    }



}
